import axios from 'axios'
let BASE_URL="https://elm.cangdu.org/"
//let BASE_URL=process.env.REACT_APP_BASEURL
//配置公共URL
let instance = axios.create({
  baseURL: BASE_URL,
});

//配置拦截器
instance.interceptors.request.use(function(config){
     // 获取token
     let token = localStorage.getItem("token");
     // token存在，放在请求头中
     if (token) {
       config.headers.Authorization = token;
     }
     return config;
   },
   function (error) {
     return Promise.reject(error);
});

//响应拦截
instance.interceptors.response.use(function(response){
    return response.data

},function(error){
return Promise.reject(error)
})
export default instance
